(function(){
    angular.module("loginCtrlModule",[])
        .controller("loginController",["$scope",
            "postDataService","userDataService","$location","$rootScope",
            function($scope,postDataService,
                     userDataService,$location,$rootScope){
                $rootScope.tishi = "";
                $scope.user = {};
                $scope.loginClick = function(){
                    $rootScope.loadingText = "玩命加载中...";
                        $rootScope.loading = true;
                    postDataService.postRequest(
                        "userInfoLogin.php",
                        {
                            username:$scope.user.name,
                            password:hex_md5($scope.user.password)
                        }
                        ,function(data){
                            $rootScope.tishi = data.data;
                            // $rootScope.loadingText = data.data;
                            $rootScope.loading = false;
                            console.log(data);
                            if(data.code==0){
                                userDataService.userData = data.data;
                                userDataService.userData.isLogin = true;
                                $location.path("/bookList");
                            }
                        },
                        function(error){
                            $rootScope.loading = false;
                            console.log(error);
                        }
                    )

                }

            }
        ])
})();